/*
 *  每日一题 y总 截断数组
 * */

#include <iostream>

using namespace std;
const int N = 100010;
int s[N];

int main() {

    long long res = 0, cnt = 0;
    int n;
    cin >> n;
    int t;
    for (int i = 1; i <= n; ++i) {
        cin >> t;
        s[i] = s[i - 1] + t;
    }

    if (s[n] % 3 != 0) {
        cout << 0;
    } else {
        for (int j = 2; j < n; ++j) {
            if (s[j - 1] == s[n] / 3) {
                cnt++;
            }
            if (s[j] == s[n] / 3 * 2) {
                res += cnt;
            }
        }
        cout << res;
    }

    return 0;
}